package com.gewu.pm.ui.activity.delivery;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.viewpager.widget.ViewPager;

import com.androidkun.xtablayout.XTabLayout;
import com.gewu.pm.R;
import com.gewu.pm.app.AppActivity;
import com.gewu.pm.app.AppFragment;
import com.gewu.pm.ui.fragment.delivery.DeliveryProviderReconciliationFragment;
import com.hjq.base.FragmentPagerAdapter;

/**
 * 配送商对账主Activity
 */
public final class DeliveryProviderReconciliationActivity extends AppActivity {

    private XTabLayout mTabLayout;
    private ViewPager mViewPager;

    private FragmentPagerAdapter<AppFragment<?>> mPagerAdapter;
    private DeliveryProviderReconciliationFragment mPendingFragment;   // 待确认
    private DeliveryProviderReconciliationFragment mConfirmedFragment; // 已确认

    public static void start(Context context) {
        Intent intent = new Intent(context, DeliveryProviderReconciliationActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.delivery_provider_reconciliation_activity;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        mTabLayout = findViewById(R.id.tab_layout);
        mViewPager = findViewById(R.id.vp_content);

        // 创建 Fragment
        mPendingFragment = DeliveryProviderReconciliationFragment.newInstance(0);    // 待确认
        mConfirmedFragment = DeliveryProviderReconciliationFragment.newInstance(1);  // 已确认

        // 设置 ViewPager
        mPagerAdapter = new FragmentPagerAdapter<>(this);
        mPagerAdapter.addFragment(mPendingFragment, "待确认");
        mPagerAdapter.addFragment(mConfirmedFragment, "已确认");
        mViewPager.setAdapter(mPagerAdapter);

        // 关联 XTabLayout 和 ViewPager
        mTabLayout.setupWithViewPager(mViewPager);
    }

    @Override
    protected void initData() {
    }
}

